package com.mairuide.phone.treeview;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.mairuide._frame.base.BaseController;
import com.mairuide.bill.treeview.BillTreeNode;

/**
 * 获取案件关联的人员手机号码
 * @author songRT
 */
@Controller
@RequestMapping("/phone")
public class PhoneTreeController extends BaseController {
	
	@Autowired
	private PhoneTreeService phoneTreeService;
	
	/**
	 * 获取案件下面的资金账户信息
	 * @param model
	 * @return
	 */
	@RequestMapping("/getPhoneTree")
	@ResponseBody
	public Object getPhoneTree(HttpServletRequest request,ModelMap model,String caseId) {
		List<BillTreeNode> trees = new ArrayList<BillTreeNode>();
		if(StringUtils.isNotEmpty(caseId)) {
			trees = phoneTreeService.getPhoneTree2(caseId);
		}else {
			BillTreeNode rootNode = new BillTreeNode();
			rootNode.setId("pid_0");//根节点
			rootNode.setName("案件人员信息");
			rootNode.setTitle("案件人员信息");
			rootNode.setPId("pid_-1");
			rootNode.setOpen(true);
			rootNode.setIsParent(true);
			trees.add(rootNode);
		}
		return SUCCESS(trees);
	}
}
